<?php
include '../AopClient.php';
include '../SignData.php';
include('../AlipayMobilePublicMultiMediaClient.php');
include('../request/AlipayMarketingCardQueryRequest.php');
include('../request/AlipayMarketingCardFormtemplateSetRequest.php');
include('../request/AlipayMarketingCardTemplateQueryRequest.php');
include('../request/AlipayMarketingCardTemplateCreateRequest.php');
$aop = new AopClient();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = '2017122101047175';
$aop->rsaPrivateKey = 'MIIEpAIBAAKCAQEA1Un4VQVFLymUaej3Ayv0Mi8f/gGzuveKzK+U6DreKmREAWGCmUCSybGAyK3auyR0TANayxq1F9nDpUkn1bbueBUknaHi0+p82dm7eKHWJOQOkfp1Wxnmg/VDi++5u+/dAY7Kc+kr7bB0NQwUyxBPhIPUFbTIhl2+nLNPEXy/jiEe+u50lghRC4mN3KiBudd45w307nqTeNdKCj6433NpYTytY/FzROMK0hglFh2SfctnrHqtmkwjEXo6ucJEHwQ1x1LXUcGv+MVInxZHiOAaFtobQXi3HdVaMva0rXxBtfT6zDLzwyRoMV+Dkn/s/pWo9RqKweAHpt4s5+axN9miXwIDAQABAoIBAQCg1HhHVAQJPidFfX/Vim1G8jYDiTEHyOWG1tdIDiu8d4K4L9kUypZlNE3SBRasix6OuvDZujfX1kMq/XDmPFyxe+/yVUH/Xg/rDb3Jhu89PiKmfN/FZFBoLKdUe93oE0TpicyrfqW7Q5U88vEy9gef+vAPthSHDWVQL/1tSE4BUyK73YetL2Zp3AuLOcDC+RcEss7r90HlAchlRdGSMAWoQ1OkmAA2BVHa3ZZD/JjXMBPS/dTggSEYkPhO79BP0N/s+EN5vLP0zZh2L1b1v6LsqXXY7+sR9/eJAbcsL3XljameiZthtcVjdpBnY9RURdv9Vcf6VqSB9r7WTelc2mjxAoGBAP2qjPm5zkIRrJSfavJx/Z/SHhrt6L9zDpUeaGTDGOlYo1dRdWF51ovFwNuHTc5oNoBtbhA41RMg0g5HfFDqFvUlga7EKdYBZodYhtfguSq417nHa181X59w2f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hk8iobT19dMhlUCR4jE1jWGTTHVHZh1OrlV1zHjkHcRdLihCyMM3WQWz5pOvDuBhtl9JVA/MaeeFEgHTxde3QIDAQAB';
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='utf-8';
$aop->format='json';

$request = new AlipayMarketingCardFormtemplateSetRequest ();
$post_data=[
  'template_id'=>'20180118000000000763343000300730',
    'fields'=>[
            'required'=>['common_fields'=>['OPEN_FORM_FIELD_MOBILE']],                                                          'optional'=>['common_fields'=>['OPEN_FORM_FIELD_GENDER']]
    ]
];
//var_dump(json_encode($post_data,JSON_UNESCAPED_UNICODE));die;
$request->setBizContent(json_encode($post_data,JSON_UNESCAPED_UNICODE));
$result = $aop->execute ( $request);

$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;
var_dump($result);
if(!empty($resultCode)&&$resultCode == 10000){
echo "成功";
} else {
echo "失败";
}